home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
sinkToilet.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
4KB
|
122 lines
-- sink state machine
beginStateMachine()
onMsg("buildMenu", function(msg)
if (repairMenu()) then return end
-- build the pie menu
clearPieMenu();
button = addPieMenuButton("pm_washHands", "washHands");
button.addDescription(ACTIVITY, "washHands");
button = addPieMenuButton("pm_brushTeeth", "brushTeeth");
button.addDescription(ACTIVITY, "brushTeeth");
button = addPieMenuButton("pm_makeHair", "makeHair");
button.addDescription(ACTIVITY, "makeHair");
-- button.addIcon("guiIconHygiene");
end )
--
onMsg("washHands", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- walk to the closest action point
local actionPoint = character.getFreeActionPoint(this, "washHands");
if (actionPoint) then
-- notify current mission
character.sendMsg("washHands", gameObjectServer.mission);
-- get the walk state object
local wso = character.walkSO;
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("sinkChar.washHandsStart", this);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
onMsg("brushTeeth", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- walk to the closest action point
local actionPoint = character.getFreeActionPoint(this, "washHands");
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("sinkChar.brushTeethStart", this);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
onMsg("makeHair", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- walk to the closest action point
local actionPoint = character.getFreeActionPoint(this, "washHands");
if (actionPoint) then
-- get the walk state object
local wso = character.walkSO;
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("sinkChar.makeHair", this);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
-- repair
onMsg("repair", function(msg)
print("onMsg repair");
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- walk to the closest action point
local actionPoint = character.getFreeActionPoint(this, "repair");
-- get the walk state object
local wso = character.walkSO;
if (actionPoint) then
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
if (wso.walkToActionPoint(actionPoint)) then
wso.queueStateMachine("repairChar.repairStart", this, wsoContext);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
end )
endStateMachine()